NSInvalidArgumentException: *** -[NSPlaceholderString initWithFormat:locale:arguments:]: nil argumen

Posted by BU on Stack Overflow See other posts from Stack Overflow or by BU
Published on 2010-03-31T12:58:40Z Indexed on 2010/03/31 13:03 UTC
Read the original article Hit count: 1343

Filed under:
|

I have no idea where in my code is causing this problem. Can someone please take a look and let me know what I am missing? The code is relatively straightforward.

+(void)processGetGameOffersByGameWithReply:(NSDictionary *)responseDictionary { GameOffer *gameOffer; @try {

    SharedResources *s = [SharedResources instance];
    GameOffersByGameTableViewController *gameOffersByGameTableViewController = [s gameOffersByGameTableViewController];
    NSMutableArray *gameOffersArray = [gameOffersByGameTableViewController gameOffersAsArray];

    NSString *dealsCountString = [[responseDictionary valueForKey:@"number_of_deals"] retain];
    NSNumber *dealsCount = [[SharedResources convertToNumberFromString:dealsCountString] retain];



    int i=0;
    NSString *keyStringForTitle;
    NSString *title, *description, *keyStringForDescription;

    for(int i=0; i < dealsCount; i++)
    {
        /*NSString *keyStringForDealID = [NSString stringWithFormat:@"DealID%d", i];
        NSString *DealIDString = [responseDictionary valueForKey:keyStringForDealID];
        NSNumber *DealID = [[SharedResources convertToNumberFromString:DealIDString] retain];*/

        keyStringForTitle = [[NSString alloc] initWithFormat:@"Title%d",i] ;
        title = [[NSString alloc] initWithFormat:[responseDictionary valueForKey:keyStringForTitle]];
        //[[responseDictionary valueForKey:keyStringForTitle] retain];

        keyStringForDescription = [[NSString alloc] initWithFormat:@"Description%d", i];
        description = [[NSString alloc] initWithFormat:[responseDictionary valueForKey:keyStringForDescription]];

        /*NSString *keyStringForGameID = [NSString stringWithFormat:@"GameID%d", i];
        NSString *GameIDString = [responseDictionary valueForKey:keyStringForGameID];
        NSNumber *GameID = [[SharedResources convertToNumberFromString:GameIDString] retain];*/

        gameOffer = [[GameOffer alloc] initWithTitle:title Description:description Image:nil];
        //int i =0;
        SharedResources *s = [SharedResources instance];
        [gameOffersArray addObject:[gameOffer retain]];
        int j=0;

    }

    NSString *temp = nil;
    int k = 0;
    //find the navigation controller
    UINavigationController *myNavigationController = [[s gamesTableViewController] navigationController];

    //push the table view controller to the navigation controller;
    [myNavigationController pushViewController:gameOffersByGameTableViewController animated:YES];
}
@catch (NSException *ex) 
{
    NSLog(@"Count is %d", [[[[SharedResources instance] gameOffersByGameTableViewController] gameOffersAsArray] count]);
    NSLog(@"\n%@\n%@", [gameOffer Title], [gameOffer Description] );
    [SharedResources LogException:ex];
}

}

The problem is whenever the program gets done with the for loop, it doesn't execute the "NSString *temp=nil" anymore, it jumps to the catch statement. I tried removing the for loop setting i = 0. The problem doesn't occur anymore. It reaches teh end of the method by adding only one object in the array. The problem only occurs if there's a for loop.

In the catch statement, even with the error, I can see that the array is filled properly and the [gameOffer Title] and [gameOffer Description] have the correct values.

Thanks so much for your help.

© Stack Overflow or respective owner

Related posts about nil

Related posts about argument